// pages/mine/mine.js
var app=getApp();
Page({
    data:{
        loginNum:0,
        url:'',
        userInfor:''
    },


    onShow(){
        let that = this
        that.setData({
            userInfor: app.globalData.userInfor
        })
        that.setData({
            loginNum: app.globalData.loginNum
          })
        //console.log(111,that.data.userInfor);       
        //console.log(111,that.data.loginNum);
    },
    goLogin(){
        wx.navigateTo({
        url: '/pages/mine/login/login',
        })
    },
    gomytest(){
        if(this.data.loginNum==0){
            this.data.url='/pages/mine/login/login';
            wx.navigateTo({
                url: this.data.url,
                })
        }else{
            this.data.url='/pages/mine/mytest/mytest';
            wx.navigateTo({
                url: this.data.url,
                })
        }
        //console.log(this.data.url);

    },
    gomyconsole(){
        if(this.data.loginNum==0){
            this.data.url='/pages/mine/login/login';
            wx.navigateTo({
                url: this.data.url,
                })
        }else{
            this.data.url='/pages/mine/myconsole/myconsole';
            wx.navigateTo({
                url: this.data.url,
                })
        }
        //console.log(this.data.url);

    },
    gomyanswer(){
        if(this.data.loginNum==0){
            this.data.url='/pages/mine/login/login';
            wx.navigateTo({
                url: this.data.url,
                })
        }else{
            this.data.url='/pages/mine/myanswer/myanswer';
            wx.navigateTo({
                url: this.data.url,
                })
        }
        //console.log(this.data.url);

    },
    gomynotice(){
        if(this.data.loginNum==0){
            this.data.url='/pages/mine/login/login';
            wx.navigateTo({
                url: this.data.url,
                })
        }else{
            this.data.url='/pages/mine/mynotice/mynotice';
            wx.navigateTo({
                url: this.data.url,
                })
        }
        //console.log(this.data.url);
    },
    gomycourse(){
        if(this.data.loginNum==0){
            this.data.url='/pages/mine/login/login';
            wx.navigateTo({
                url: this.data.url,
                })
        }else{
            this.data.url='/pages/mine/mycourse/mycourse';
            wx.navigateTo({
                url: this.data.url,
                })
        }
        //console.log(this.data.url);

    },
    goPerson(){
        if(this.data.loginNum==0){
            this.data.url='/pages/mine/login/login';
            wx.navigateTo({
                url: this.data.url,
                })
        }else{
            this.data.url='/pages/mine/myphone/myphone';
            wx.navigateTo({
                url: this.data.url,
                })
        }
        //console.log(this.data.url);
    },
    gomypassword(){
        if(this.data.loginNum==0){
            this.data.url='/pages/mine/login/login';
            wx.navigateTo({
                url: this.data.url,
                })
        }else{
            this.data.url='/pages/mine/mypassword/mypassword';
            wx.navigateTo({
                url: this.data.url,
                })
        }
        //console.log(this.data.url);

    },
    goaboutour(){
        if(this.data.loginNum==0){
            this.data.url='/pages/mine/login/login';
            wx.navigateTo({
                url: this.data.url,
                })
        }else{
            this.data.url='/pages/mine/aboutour/aboutour';
            wx.navigateTo({
                url: this.data.url,
                })
        }
        //console.log(this.data.url);

    },

    logout(){
        let that = this;
        wx.showModal({
            title: '退出登录',
            content: '你确定要退出吗？',
            success: function (res) {
                if (res.confirm) {
                    //console.log(that.data.userInfor);
                    app.globalData.loginNum=0;
                    app.globalData.userInfor='';
                    that.setData({
                        loginNum: app.globalData.loginNum,
                        userInfor:app.globalData.userInfor
                    });
                    that.onShow();        
                    wx.request({
                        url: app.globalData.URL+'user/updateU',
                        method:'PUT',
                        data:that.data.userInfor,
                        header: {
                            'content-type': 'application/json' // 设置请求头，指定数据格式为 JSON
                            },
                            success: function(res){
                            if(res.data.code==1){
                                //console.log(res);
                            }
                        }
                    })
                } 
            }
        });
        
    }

})